//
//  UIbuttom + Extension.swift
//  czWB
//
//  Created by Qing on 2018/5/30.
//  Copyright © 2018年 成哥哥. All rights reserved.
//

import UIKit



extension UIButton {
    
    /// 可以设置button前景图和背景图
    ///
    /// - Parameters:
    ///   - imageName: 前景图名
    ///   - backImageName: 背景图名
    class func cz_buttonImage(_ imageName: String, backImageName: String) -> UIButton {
        
        let btn = UIButton()
        btn.setImage(UIImage(named: imageName), for: UIControl.State.normal)
        btn.setBackgroundImage(UIImage(named: backImageName), for: UIControl.State.normal)
        btn.sizeToFit()
        
        return btn
    }
    
    
    /// 可以设置字体大小，正常状态颜色，点击状态颜色
    ///
    /// - Parameters:
    ///   - title: 抬头
    ///   - fontSize: 字体大小
    ///   - normalColor: 正常状态颜色
    ///   - highlightColor: 高亮状态颜色
    class func cz_textButton(title: String, fontSize: CGFloat, normalColor: UIColor, highlightColor: UIColor) -> UIButton {
        
        let btn = UIButton(type: .custom)

        btn.titleLabel?.font = UIFont.systemFont(ofSize: fontSize)
        
        btn.setTitle(title, for: .normal)
        
        btn.setTitleColor(normalColor, for: UIControl.State.normal)
        
        btn.setTitleColor(highlightColor, for: UIControl.State.highlighted)
    
        return btn
    }
    
    
}
